
#ifndef MacroDefine_h
#define MacroDefine_h


/***************************** 系统尺寸 ***************************/

//程序屏幕大小
#define SCREEN_WIDTH                 ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT                ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_BOUNDS                [[UIScreen mainScreen] bounds]


//判断版本ios
#define IOS_VERSION                 ([[[UIDevice currentDevice] systemVersion] floatValue])

//#define IsPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)
#define IsPhoneX    [PlatformTools isSpecificScreen]




#define GetRectNavAndStatusHight  (self.navigationController.navigationBar.frame.size.height+[[UIApplication sharedApplication] statusBarFrame].size.height)


#define  kDefalutCellRowHeight 44.0

#define  kUtilsAppDelegate            ((AppDelegate *)[[UIApplication sharedApplication] delegate])

#define  IsScreenWidthFor320  (SCREEN_WIDTH == 320)


/***************************** 字符操作 *****************************/
//字符串是否为空
#define IsEmptyStr(_ref)    (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) ||([(_ref)isEqualToString:@""]))

//转换空字符串为非空
#define AvoidNullString(_ref)  _ref = IsEmptyStr(_ref) ? @"" : _ref


//格式化字符串宏
#define kFormatString(fmt, ...)   [NSString stringWithFormat:fmt, ##__VA_ARGS__]


#define kSetNavitationBarTitle(titleStr)  self.navigationItem.title = titleStr





/***************************** 日志 *****************************/

#if defined(DEBUG)||defined(_DEBUG)

#define  CLog(...)  NSLog(__VA_ARGS__)
#define CDebugLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )


#define BigCLog(format, ...)   printf("%s", [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] )

#else

#define  CLog(...)
#define CDebugLog( s, ... )
#define BigCLog(format, ...)
#endif






#define LogDealloc CLog(@"%@ dealloc",NSStringFromClass([self class]));


#define LogDeallocFunc \
    - (void)dealloc{ \
        LogDealloc   \
      }




/////        时间戳    ////////


#define  InitTimeStamp \
    NSTimeInterval begin, end, time; \

#define  StartTimeStamp  \
    begin = CACurrentMediaTime();


#define  EndTimeStamp(msg)  \
    end = CACurrentMediaTime(); \
    time = end - begin; \
    CDebugLog(@"%@ Time Stamp:%8.2f ms",msg,time * 1000);



////////        weak strong self    ////////

#define WeakSelf(weakSelf)      __weak __typeof(&*self)    weakSelf  = self;
#define StrongSelf(strongSelf)  __strong __typeof(&*self) strongSelf = weakSelf;

#define   HideNavigatonBarShadowLine    [self.navigationController.navigationBar setShadowImage:[UIImage new]];

#define   SetTableViewHeaderView \
        self.view.backgroundColor = kBackgroundViewColor;\
        self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kCellSpacingHeight)];\
        self.tableView.tableHeaderView.backgroundColor = kBackgroundViewColor;

////////////////        marco  property define     ////////////////////////


/**
图像的快速定义
 @param propertyName propertyName description
 @param imageName imageName description
 @return return value description
 */
#define MACRO_UIImageView(propertyName,imageName) \
    - (UIImageView *)propertyName{ \
        if (!_##propertyName) {\
            _##propertyName = [[UIImageView alloc]init];\
            _##propertyName.image = [UIImage imageNamed:imageName];\
        }\
        return _##propertyName;\
    }

#define MACRO_UIImageView_Lazyload(propertyName,imageName) \
    - (UIImageView *)propertyName{ \
        if (!_##propertyName) {\
            _##propertyName = [[UIImageView alloc]init];\
            _##propertyName.image = [UIImage imageNamed:imageName];\
        }\
        return _##propertyName;\
    }

#define MACRO_UIImageView_LazyloadNoImage(propertyName) \
    - (UIImageView *)propertyName{ \
        if (!_##propertyName) {\
            _##propertyName = [[UIImageView alloc]init];\
        }\
        return _##propertyName;\
    }



#define MACRO_UILabel(lblProperty) \
    - (UILabel *)lblProperty{ \
        if (!_##lblProperty) {\
                _##lblProperty = [[UILabel alloc]init];\
            }\
            return _##lblProperty;\
        }

/**
 懒加载定义UILabel
 */
#define MACRO_UILabel_Lazyload(lblProperty) \
    - (UILabel *)lblProperty{ \
        if (!_##lblProperty) {\
            _##lblProperty = [[UILabel alloc]init];\
        }\
        return _##lblProperty;\
    }

#define MACRO_UILabelWithPFCGFont(lblProperty,textStr,color,fontSize) \
    - (UILabel *)lblProperty{ \
        if (!_##lblProperty) {\
        _##lblProperty = [[UILabel alloc]init];\
        _##lblProperty.text = textStr;\
        _##lblProperty.textColor = color;\
        _##lblProperty.font = PingFangZhongChangGuiForFont(fontSize);\
        }\
        return _##lblProperty;\
    }


#define MACRO_UILabel_LazyloadWithPFCGFont(lblProperty,textStr,color,fontSize) \
    - (UILabel *)lblProperty{ \
        if (!_##lblProperty) {\
            _##lblProperty = [[UILabel alloc]init];\
            _##lblProperty.text = textStr;\
            _##lblProperty.textColor = color;\
            _##lblProperty.font = PingFangZhongChangGuiForFont(fontSize);\
        }\
        return _##lblProperty;\
    }

#define MACRO_UILabel_LazyloadNoTextWithPFCGFont(lblProperty,color,fontSize) \
    - (UILabel *)lblProperty{ \
        if (!_##lblProperty) {\
        _##lblProperty = [[UILabel alloc]init];\
        _##lblProperty.textColor = color;\
        _##lblProperty.font = PingFangZhongChangGuiForFont(fontSize);\
        }\
        return _##lblProperty;\
    }

/**
 懒加载定义UILabel(使用PingFangSC-Regular)
 */
#define MACRO_UILabel_LazyloadWithPFCGFont(lblProperty,textStr,color,fontSize) \
    - (UILabel *)lblProperty{ \
        if (!_##lblProperty) {\
            _##lblProperty = [[UILabel alloc]init];\
            _##lblProperty.text = textStr;\
            _##lblProperty.textColor = color;\
            _##lblProperty.font = PingFangZhongChangGuiForFont(fontSize);\
        }\
        return _##lblProperty;\
    }

/**
 懒加载定义UILabel(使用PingFangSC-Medium)
 */
#define MACRO_UILabel_LazyloadNoTextWithPFCGMediumFont(lblProperty,color,fontSize) \
    - (UILabel *)lblProperty{ \
        if (!_##lblProperty) {\
            _##lblProperty = [[UILabel alloc]init];\
            _##lblProperty.textColor = color;\
            _##lblProperty.font = PingFangZhongChangGui_MediumForFont(fontSize);\
        }\
        return _##lblProperty;\
    }


/**
 配置UILabel 属性
 */
#define  MACRO_UILabel_Configure(lblProperty,textStr,color,fontSize) \
    lblProperty.textColor = color;\
    lblProperty.text = textStr;\
    lblProperty.font = PingFangZhongChangGuiForFont(fontSize);


#define  MACRO_UILabel_ConfigureNoFontSize(lblProperty,textStr,color) \
    lblProperty.textColor = color;\
    lblProperty.text = textStr;

/**
 UI View的快速定义
 */
#define MACRO_UIView(propertyName,color)    \
    UIView *propertyName =  [[UIView alloc]init];\
    propertyName.backgroundColor = color;

#define MACRO_UIView_Lazyload(propertyName,color)    \
    - (UIView *)propertyName{ \
        if (!_##propertyName) {\
        _##propertyName = [[UIView alloc]init];\
        _##propertyName.backgroundColor = color;\
        }\
        return _##propertyName;\
    }

/**
 NSMutableArray 的快速定义
 */
#define MACRO_MutableArray_Lazyload(arrayProperty) \
    - (NSMutableArray *)arrayProperty{ \
        if (!_##arrayProperty) {\
            _##arrayProperty = [NSMutableArray array];\
        }\
        return _##arrayProperty;\
    }




/**
 多行显示
 */
#define  kMultipleLineDisplayControl(control)  \
        control.numberOfLines = 0;\
        control.lineBreakMode = NSLineBreakByWordWrapping;




//////
//translucent为YES，控制器view从（0，0）开始；translucent为NO，控制器view从（0，64）开始。

//  **  线程宏 **/
#define kCedarDispatchAsyncOnMainQueue(x) \
    __weak typeof(self) weakSelf = self; \
    dispatch_async(dispatch_get_main_queue(), ^{ \
        typeof(weakSelf) self = weakSelf; \
        {x} \
    });



#define kCedarDispatchAsyncOnGlobalDefaultQueue(x) \
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ \
    {x} \
    });


//脚本自减
#define BadgeNumberSelfReduction  \
    if ([UIApplication sharedApplication].applicationIconBadgeNumber >0) {\
        [UIApplication sharedApplication].applicationIconBadgeNumber--;\
    }

#define ResetBadgeNumberForZero \
    if ([UIApplication sharedApplication].applicationIconBadgeNumber >0) {\
        [UIApplication sharedApplication].applicationIconBadgeNumber = 0;\
    }






#endif /* MacroDefine_h */
